<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>延迟3秒发起带参的GET请求</title>
</head>
<body>
  <script>
      setTimeout(function() {
        // 1.创建 XHR 对象
        var xhr = new XMLHttpRequest()
        // 2.调用 open 函数
        xhr.open('GET','http://api.tianapi.com/duilian/index?key=728e18709a9c7c5a2c22b8152fee7f8b')
        // 3.调用 send 函数
        xhr.send()
        //4.监听 onreadystatechange 事件
        xhr.onreadystatechange = function(){
          if(xhr.readyState === 4 && xhr.status === 200){
            //获取服务器响应的数据
            console.log(xhr.responseText);
          }
        } 
      },3000)
    
 
  </script>
</body>
</html>